#!/usr/bin/python
 #-*-coding:utf-8-*-  
'''
Created on 2016年12月13日

@author: sunying
'''
import time,json,os,random
from random import choice

# 获取当前日期
def getCurrentDate():
#     return time.strftime('%Y%m%d',time.localtime(time.time()))
    times = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
    return times
def getString(module_name,class_name):
#     module_name = "test_site_monitor"
#     class_name = "TestSiteMonitorSmoke"
#     expath ='/Users/sunying/Desktop/cloudwise/eclipse_work/QA-Automation-master/API_Automation/post_data/test_site_monitor/TestSiteMonitorSmoke/'
    expath ='/Users/sunying/Desktop/cloudwise/eclipse_work/QA-Automation-master/API_Automation/post_data/'  + module_name +'/'+class_name +'/'
    filename = expath + '1.json'
    print filename
#     fo = open(filename, 'r')
#     fs = fo.read()
#     fo.close()
#     fd = json.loads(fs)
#     return fd
    f = open(filename)             # 返回一个文件对象  
    line = f.readline()             # 调用文件的 readline()方法  
    print line
#     json转字符串
    line_json = json.dumps(line)
    print line_json
#     字符串中内容替换
    line_json_replace =  line_json.replace("viv_site_monitor_http",getCurrentDate());
    print line_json_replace
#     字符串转json
    print  json.loads(line_json_replace)
if __name__ == "__main__":
    print getCurrentDate()
#      module_name = "test_site_monitor"
#      class_name = "TestSiteMonitorSmoke"
#      getString(module_name,class_name)
#     y=list(range(200,500))
#     s = random.sample(y, 1)  #从list中随机获取5个元素，作为一个片断返回  
#     print (s)  
#     print (y)
#     foo = [200,500]
#     print choice(foo)
    